﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.Content;
using Android.Media;
using Android.OS;
using Android.App;
using Android.Test.Mock;
using Android.Views;
using GBU.Activities;
using Android.Util;

namespace GBU.Services.Pedometer
{
    public class StepServiceConnection:IServiceConnection
    {
        private Handler mHandler;
        private StepServiceCallback mCallback;
        private StepService mService;
        private const string Tag = "StepConn";

        public StepServiceConnection(StepServiceCallback callback,Handler mhandler)
        {
            mCallback = callback;
            mHandler = mhandler;
        }

        public void Dispose()
        {
            //throw new NotImplementedException();
        }

        public IntPtr Handle { get; private set; }
        public void OnServiceConnected(ComponentName name, IBinder service)
        {
           // throw new NotImplementedException();
            Log.Debug(Tag, "On Stepservice connected");
            mService = (service as StepBinder).GetStepService();
            if (mService != null)
            {
                //activity.BindService(activity.Intent);
                //servicei.RegisterCallback();
                mService.RegisterCallback(mCallback);
            }
        }

        public void OnServiceDisconnected(ComponentName name)
        {
              Log.Debug(Tag, "On Stepservice Disconnected");
           // throw new NotImplementedException();
            mService = null;
        }

      
    }
}
